#!/usr/bin/python3
# -*- coding: UTF-8 -*-

import tkinter as tk
import config
import gui
import socket


BUFSIZE = 1460
# svr_addr = '/tmp/gpio_socket'
svr_addr = socket.gethostname()
svr_port = 65512

try:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    # sock.connect(svr_addr)
    sock.connect((svr_addr, svr_port))

    gui.gpio_init(sock)

    window = tk.Tk()
    window.title('监控')

    photo = tk.PhotoImage(file=config.welcome_img)
    gui.Step1(window, photo, sock)

    window.mainloop()

except Exception as e:
    raise e

finally:

    gui.gpio_deinit()
    sock.close()
